<%@page import="model.Room"%>
<%@page import="model.AvailableRoom" %>
<%@page import="dao.impl.RoomDaoImpl"%>
<%@page import="dao.intf.RoomDao" %>
<%@page import="dao.impl.AvailableRoomDaoImpl"%>
<%@page import="dao.intf.AvailableRoomDao" %>
<%@page import="java.util.ArrayList" %>
<%@page import="java.util.List" %>
<%@page import="java.util.*" %>
<%@page import="model.RoomType"%>
<%@page import="model.Reservation"%>
<%@page import="dao.impl.RoomTypeDaoImpl"%>
<%@page import="dao.intf.RoomTypeDao" %>
<%@page import="java.text.SimpleDateFormat;" %>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML>
<html>
<head>
    <title>Hotel Arbour : Modify Reservation</title>    
	<script src="js/jquery-1.9.1.js" language="javascript"></script>
	<script src="js/jquery-ui-1.10.2.custom.js" language="javascript"></script>
	<script type="text/javascript" src="js/post_watermarkinput.js"></script>
	<link rel="stylesheet" href="CSS/ui-lightness/jquery-ui-1.10.2.custom.css" type="text/css">
	<link href="CSS/vasplus_programming_blog_CSS.css" rel="stylesheet" type="text/css">
	
	
	
<script>
	$(function() {
		//$( "#accordion" ).accordion();	
		
		var date = new Date();
		var currentYear = date.getFullYear();
		var currentMonth = date.getMonth();
		var currentDate = date.getDate();
		var currentDate2 = date.getDate() + 1;
		
		$("#checkindate").datepicker({
			onSelect: function (date) {
				if ($("#checkindate").val() != '' && $("#checkoutdate").val() != ''){
					var start = $('#checkindate').datepicker('getDate');
				    var end = $('#checkoutdate').datepicker('getDate');
				    var diff = (end - start)/1000/60/60/24;
					$("#night").val(diff);
					//alert(diff);
				}            
	        },
			dateFormat: "yy-mm-dd",
			minDate:new Date(currentYear, currentMonth, currentDate)
		});
		
		$("#checkoutdate").datepicker({
			onSelect: function (date) {
				if ($("#checkindate").val() != '' && $("#checkoutdate").val() != ''){
					var start = $('#checkindate').datepicker('getDate');
				    var end = $('#checkoutdate').datepicker('getDate');
				    var diff = (end - start)/1000/60/60/24;
					$("#night").val(diff);
					//alert(diff);
				}
	            
	        },
			dateFormat: "yy-mm-dd",
			minDate:new Date(currentYear, currentMonth, currentDate2)		
		});
		
	});	
	
	
</script>
<script>
$(document).ready(function() { 
	
	//if ($('#checkindate').onSelect == true) alert ('checkin');
	
    $('#btnRates').click(function(event) { 
    	var msg = '';
    	if ($('#checkindate').val() == '') 
			msg = msg + 'Please select Check In date.\n';
    	if ($('#checkoutdate').val() == '') 
			msg = msg  + 'Please select Check Out date.\n';	
    	if ($('#adult').val() == '' )
			msg = msg  + 'Please enter number of Adult(s).\n';
		if ($('#children').val() == '' )
			msg = msg  + 'Please enter number of Children.\n';
		if (parseInt($('#night').val()) < 1 )
			msg = msg  + 'Checkin date must be earlier than Checkout date.\n';
		
		if (msg != '' ) alert (msg);
		else{
			
			$('#frmModifyAvail').submit(); 	
	        
	        
		}//end else
    	
    });
});
$(document).ready(function(){	
	
	//$('#availability').attr('style' , 'display:none');
	$('#rooms').keypress(function(event){		
		if (event.charCode > 31 && (event.charCode < 48 || event.charCode > 57)) {
			return false;
		}
	}); 
	$('#adult').keypress(function(event){		
		if (event.charCode > 31 && (event.charCode < 48 || event.charCode > 57)) {
			return false;
		}
	});
	$('#children').keypress(function(event){		
		if (event.charCode > 31 && (event.charCode < 48 || event.charCode > 57)) {
			return false;
		}		
	});
	$('#night').keypress(function(event){		
		if (event.charCode > 31 && (event.charCode < 48 || event.charCode > 57)) {
			return false;
		}
	});	
});


	
</script>

</head>
 
<body style="font-family:Calibri;">

<form action="Home" id="frmModifyAvail" name="frmModifyAvail" method="POST">
<!--  <form id="frmIndex" name="frmIndex" action="HOME" method="POST">-->
	
	 <input type="hidden" value="1" name="checkrates" id="checkrates">
	 <input type="hidden" value="1" name="fromModify" id="fromModify">

	<div id="body" style="width:900px ;margin:0 auto; padding:0 0 0 0 auto;align:center;">
	<!-- Header-->		
		
		<table width="100%" border="0px" cellpadding="0">
		<tr>
			<td style="width:10%;"></td>
			<td style="width:32.5%;"><img src="images/logo.jpg" /></td>
			
			<td>
				<p align="left" style="font-weight:bold;">			
					<a href="index.jsp" style="text-decoration:none;"><font style="color:#7E354D">Home&nbsp;&nbsp;|&nbsp;&nbsp;</font></a>
					<a href="index.jsp" style="text-decoration:none;"><font style="color:#7E354D">Promotion&nbsp;&nbsp;|&nbsp;&nbsp;</font></a>
					<a href="index.jsp" style="text-decoration:none;"><font style="color:#7E354D">Rooms&nbsp;&nbsp;&nbsp;</font></a>						
				</p> 
				<p align="right" style="font-weight:bold;">
					<div id="login_response"></div>	
				</p>					
				
			</td>
		</tr>
        <tr>
        	<td style="width:10%;"></td>
            <td style="width:65%;vertical-align:top;" colspan="2">
				<video width="600" height="260" controls>
				<source src="movie.mp4" type="images/Sample.mp4 "></source></video>
				
            </td>	
            
        </tr>
        <tr><td>&nbsp;</td></tr>
        <tr><td>&nbsp;</td></tr>
			
    </table>
    <%
   			Reservation reservation=new Reservation();
    		reservation=(Reservation)session.getAttribute("reservation");
    		
			String checkin = "";
			String checkout = "";
			String checkroomtype = "";
			String checkunit = "";
			String checkadult = "";
			String checkchildren = "";
			String checknights = "";
			String bookingid = "";
			String bookingemail = "";
			
    		if(reservation!=null)
			{ checkin = new SimpleDateFormat("yyyy-MM-dd").format(reservation.getBooking().getStart());
			  checkout= new SimpleDateFormat("yyyy-MM-dd").format(reservation.getBooking().getEnd());
			  checkroomtype = reservation.getBooking().getRoomType();
			  checkunit = reservation.getBooking().getNumberofUnits();
			  checkadult =reservation.getBooking().getAdults()+"";
			  checkchildren =reservation.getBooking().getChildren()+"";
			  checknights= reservation.getBooking().getDuration()+"";
			  bookingid = reservation.getBooking().getId();
			  bookingemail=reservation.getUser().getEmail();
			}
			
			/*String checkin = request.getParameter("bookindate");
			String checkout = request.getParameter("bookoutdate");
			String checkroomtype = request.getParameter("bookroomtype");
			String checkunit = request.getParameter("bookunit");
			String checkadult = request.getParameter("bookadult");
			String checkchildren = request.getParameter("bookchildren");
			String checknights = request.getParameter("booknights");
			String bookingid = request.getParameter("bookingid");
			String bookingemail = request.getParameter("bookemail");*/
			
			
		%> 
		<input type="hidden" id="bookingid" name="bookingid" value='<% out.println(bookingid);%>'>
		<input type="hidden" id="bookingemail" name="bookingemail" value='<% out.println(bookingemail);%>'>
    <table width="100%" border="0px" cellpadding="0" cellspacing="10px" style="font-size:15px;-khtml-border-radius: 20px;-moz-border-radius: 20px;-ms-border-radius: 20px;-o-border-radius: 20px;-webkit-border-radius: 20px;border-radius: 20px;
				border: solid 1px gray;" >
		
		
    	<tr>
    		<td style="width:30%;">&nbsp;</td>
    		<td style="width:20%;">Check-In:</td>
    		<td><input type="text" id="checkindate"  name="checkindate" readonly="readonly" value='<% out.println(checkin);%>'/></td>
    		
    	</tr>
    	
    	<tr>
    		<td style="width:30%;">&nbsp;</td>		
			<td>Check-Out:</td>
			<td><input type="text" id="checkoutdate" name="checkoutdate" value='<% out.println(checkout);%>'/></td>
		
		</tr>
		<tr>
			<td style="width:30%;">&nbsp;</td>
			<td>Room Type:</td>	
			<td>
				<%
		    	
			    	List<RoomType> roomTypeList = new ArrayList<RoomType>();
			    	RoomTypeDaoImpl roomTypeDaoObj = new dao.impl.RoomTypeDaoImpl();
			    	roomTypeList = roomTypeDaoObj.getRoomTypeList();
			    	
			    	for (int i = 0 ; i < roomTypeList.size() ; i ++){								    		
			    		if (roomTypeList.get(i).getId().equals(checkroomtype)) {
			    			out.println("<input type='text' name='roomname' id='roomname' value='"+roomTypeList.get(i).getName() + "' readonly='true'/>");	
			    			out.println("<input type='hidden' name='roomtype' id='rootype' value='"+roomTypeList.get(i).getId() + "' readonly='true'/>");	
			    		}																				
					}	
				%>
			</td>											
		    
             
		</tr>
		<tr>
			<td style="width:30%;">&nbsp;</td>
			<td colspan="2">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rooms:
				&nbsp;&nbsp;&nbsp;&nbsp;Adult:
				&nbsp;&nbsp;&nbsp;&nbsp;Children:
				&nbsp;&nbsp;&nbsp;&nbsp;Nights:
				<br>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="rooms" name="rooms" size="2" maxlength="3" value='<% out.println(checkunit);%>' readonly="true"/>&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="adult" name="adult" size="2" maxlength="3" value='<% out.println(checkadult);%>'/>&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="children" name="children" size="2" maxlength="1" value='<% out.println(checkchildren);%>'/> 
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="night" name="night" size="2" maxlength="3" value='<% out.println(checknights);%>'/>&nbsp;
					
			</td>
		
		</tr> 
		<tr>
			<td style="width:30%;">&nbsp;</td>
			<td colspan="2">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" id="btnRates" value="Check Rates"/>&nbsp;
			</td>
		
		</tr>
    </table>
    
	
    <!-- Header-->	
	
	<!-- Content -->
  
       
   <!-- Content -->
 	
   </div>
</form>
</body>
</html>
